﻿using Devonline.AspNetCore;

namespace Devonline.Database.NoSQL;

/// <summary>
/// NoSQL 数据库服务
/// </summary>
public interface INoSQLDataService
{
    /// <summary>
    /// 写入一行记录到数据库
    /// </summary>
    /// <typeparam name="TModel">数据对象模型的类型</typeparam>
    /// <param name="model">要写入的数据</param>
    /// <returns></returns>
    Task WriteAsync<TModel>(TModel model) where TModel : class, new();
    /// <summary>
    /// 写入多行记录到数据库
    /// </summary>
    /// <typeparam name="TModel">数据对象模型的类型</typeparam>
    /// <param name="data">要写入的数据</param>
    /// <returns></returns>
    Task WritesAsync<TModel>(IEnumerable<TModel> data) where TModel : class, new();

    /// <summary>
    /// 从数据库查询记录
    /// </summary>
    /// <typeparam name="TModel">数据对象模型的类型</typeparam>
    /// <typeparam name="TQueryRequest">查询请求表达式的类型</typeparam>
    /// <param name="request">查询请求表达式</param>
    /// <returns>查询结果</returns>
    Task<IEnumerable<TModel>> QueryAsync<TModel, TQueryRequest>(TQueryRequest request) where TModel : class, new() where TQueryRequest : PagedRequest;
}